package com.bokee.archerwq.lab.socket.cs;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

//import org.apache.log4j.Logger;

public class Server {

	// private static Logger logger = Logger.getLogger("Server");

	public Server() throws IOException {
		super();
	}

	public static void main(String[] args) {
		try {
			// logger.info("Try listening on port 19999 ...");
			System.out.println("Try listening on port 19999 ...");
			ServerSocket listener = new ServerSocket(19999);
			// logger.info("OK!");
			System.out.println("OK!");

			while (true) {
				Socket processor = listener.accept();
				// logger.info("A connection come.");
				System.out.println("A connection come.");
				WorkerThread worker = new WorkerThread(processor);
				// logger.info("Thread " + WorkerThread.threadCount +
				// " start!");
				System.out.println("Thread " + WorkerThread.threadCount
						+ " start!");
				worker.start();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}
